<?php
/**
 * Created by PhpStorm.
 * User: wangye
 * Date: 19-3-12
 * Time: 下午3:43
 */
header('content-type:text/html;charset=utf-8');
$host = '127.0.0.1';
$dbname = 'o2o';
$username = 'o2o';
$port = '3306';
$password = 'ixRfN736mKBMp4pX';

$pdo = new PDO("mysql:host={$host};port={$port};dbname={$dbname};port=","{$username}","{$password}");

$pdo->exec('SET NAMES UTF8');
$pdo->beginTransaction();

//$sql = 'SELECT * FROM `o2o_bis` WHERE id=:id';
$sql = 'UPDATE `o2o_bis` SET name=\'大王\' WHERE id=:id';

$stmt = $pdo->prepare($sql);

$id = 2;
//$stmt->bindParam(1,$id);
//$stmt->bindValue(1,2);
//$stmt->bindParam(':id',$id);
//$stmt->execute();
//$res = $stmt->fetchAll(PDO::FETCH_ASSOC);

$stmt->bindParam(':id',$id);
$res = $stmt->execute();

var_dump($res);

if ($res>0) {
    $pdo->commit();
    echo '成功';
}else{
    $pdo->rollBack();
    echo '失败';
}
$pdo->setAttribute(PDO::ATTR_AUTOCOMMIT,1);